package com.newland.esp.service.echarts;

import com.newland.esp.entity.deviceEntity.DeviceInfoEntity;
import com.newland.esp.mapper.echarts.BarMapper;
import com.newland.esp.vo.response.echarts.BarVo;
import com.newland.esp.vo.response.echarts.PieAndBarVO;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @param
 * @author lw
 * @descripe
 * @date 2021/8/22 10:48
 * @Version 1.0
 **/
@Service
public class BarServiceImpl implements BarService{
    @Resource
    BarMapper barMapper;

    @Override
    public BarVo getBarDate() {
        List<PieAndBarVO> barVos = barMapper.selectDeviceCount();
        ArrayList<String> names = new ArrayList<>();
        ArrayList<Integer> count = new ArrayList<>();
        for (PieAndBarVO barVo : barVos) {
            names.add(barVo.getName());
            count.add(barVo.getCount());
        }
        BarVo barVo = new BarVo(names, count);
        return barVo;
    }
}
